//Primera practica - Compiladores 2 - Semestre Uno 2012

package CSS;

import Bitacora.*;
import java_cup.runtime.Symbol;

%%

%public
%class EscanerCSS
%cup
%char
%line
%column
%full
%eofval{
    return new Symbol(SimbolosCSS.EOF, yyline+1, yycolumn +1, yytext());
%eofval}

    LineTerminator = \r|\n|\r\n
    InputCharacter = [^\r\n]

// Comentarios

    Comment = {TraditionalComment} | {EndOfLineComment} 
    TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/"
    EndOfLineComment = "//" {InputCharacter}* {LineTerminator}

// Tokens

    Letras = [a-zA-Z]*

    Cadena = [_]*{Letras} | [_]*{Letras} [_]*[a-zA-Z0-9]*

    Numero = 0 | [1-9][0-9]*

    Punto = "."

    Decimal = {Numero}{Punto}{Numero}

    new_line = \r|\n|\r\n;

    white_space	= {new_line} | [ \t\f]
	
%%

{Comment}   { /*Comentarios ignorados*/ }		

"attribute" {   
                System.out.println("Palabra reservada: \"Attribute\"");
                return new Symbol(SimbolosCSS.atributo, yyline+1, yycolumn +1, yytext());
            }

"public"    {   
                System.out.println("Palabra reservada: \"Public\"");
                return new Symbol(SimbolosCSS.publico, yyline+1, yycolumn +1, yytext());
            }

"private"   {   
                System.out.println("Palabra reservada: \"Private\"");
                return new Symbol(SimbolosCSS.privado, yyline+1, yycolumn +1, yytext());
            }

"protected" {   
                System.out.println("Palabra reservada: \"Protected\"");
                return new Symbol(SimbolosCSS.protegido, yyline+1, yycolumn +1, yytext());
            }

"static"    {   
                System.out.println("Palabra reservada: \"Static\"");
                return new Symbol(SimbolosCSS.estatico, yyline+1, yycolumn +1, yytext());
            }

"int"       {   
                System.out.println("Palabra reservada: \"Int\"");
                return new Symbol(SimbolosCSS.entero, yyline+1, yycolumn +1, yytext());
            }

"boolean"   {   
                System.out.println("Palabra reservada: \"Boolean\"");
                return new Symbol(SimbolosCSS.boleano, yyline+1, yycolumn +1, yytext());
            }

"char"      {   
                System.out.println("Palabra reservada: \"Char\"");
                return new Symbol(SimbolosCSS.caracter, yyline+1, yycolumn +1, yytext());
            }

"String"    {   
                System.out.println("Palabra reservada: \"String\"");
                return new Symbol(SimbolosCSS.cadenacaracter, yyline+1, yycolumn +1, yytext());
            }

"float"     {   
                System.out.println("Palabra reservada: \"Float\"");
                return new Symbol(SimbolosCSS.flotante, yyline+1, yycolumn +1, yytext());
            }

"method"    {   
                System.out.println("Palabra reservada: \"Method\"");
                return new Symbol(SimbolosCSS.metodo, yyline+1, yycolumn +1, yytext());
            }

"void"      {   
                System.out.println("Palabra reservada: \"Void\"");
                return new Symbol(SimbolosCSS.nulo, yyline+1, yycolumn +1, yytext());
            }

"parameter" {   
                System.out.println("Palabra reservada: \"Parameter\"");
                return new Symbol(SimbolosCSS.parametro, yyline+1, yycolumn +1, yytext());
            }

"relation"  {   
                System.out.println("Palabra reservada: \"Relation\"");
                return new Symbol(SimbolosCSS.relacion, yyline+1, yycolumn +1, yytext());
            }

{Numero}    {   
                System.out.println("Numero entero");
                return new Symbol(SimbolosCSS.numero, yyline+1, yycolumn +1, yytext());
            }
	
{Cadena}    {   
                System.out.println("Cadena de caracteres");
                return new Symbol(SimbolosCSS.cadena, yyline+1, yycolumn +1, yytext());
            }

{Decimal}   {   
                System.out.println("Numero decimal");
                return new Symbol(SimbolosCSS.decimal, yyline+1, yycolumn +1, yytext());
            }

"{"         {   
                System.out.println("Llave abierta");
                return new Symbol(SimbolosCSS.llaveabierta, yyline+1, yycolumn +1, yytext());
            }

"}"         {   
                System.out.println("Llave cerrada");
                return new Symbol(SimbolosCSS.llavecerrada, yyline+1, yycolumn +1, yytext());
            }

":"         {   
                System.out.println("Dos puntos");
                return new Symbol(SimbolosCSS.dospuntos, yyline+1, yycolumn +1, yytext());
            }

","         {   
                System.out.println("Coma");
                return new Symbol(SimbolosCSS.coma, yyline+1, yycolumn +1, yytext());
            }

";"         {   
                System.out.println("Punto coma");
                return new Symbol(SimbolosCSS.puntocoma, yyline+1, yycolumn +1, yytext());
            }

"\""        {   
                System.out.println("Comillas");
                return new Symbol(SimbolosCSS.comillas, yyline+1, yycolumn +1, yytext());
            }

{white_space}   { /* ignoramos espacios */ }

.|\n        {	IDE.Face.errores_lexicos.add(new Info(yytext(),yyline+1,yycolumn+1,0,"El caracter no pertenece al lenguaje.","Lexico"));    }